package com.gitee.xmhzzz.component.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
  * @ClassName
  * @Description
  * @Author wzq
  * @Date 2023/12/17 19:21
  * @Version 1.0
  */
@Getter
@AllArgsConstructor
public enum EnvironmentEnum {


    LOCAL("local","本地环境"),
    DEV("dev","开发环境"),
    SIT("test","测试环境"),
    UAT("uat","预发环境"),
    PROD("prod","生产环境");

    private String code;
    private String desc;

    public static EnvironmentEnum of(String code) {
        return Arrays.stream(EnvironmentEnum.values()).filter(e -> e.code.equals(code)).findAny().orElse(null);
    }

    public static String getDesc(String code) {
        for (EnvironmentEnum e : EnvironmentEnum.values()) {
            if (e.code.equals(code)) {
                return e.desc;
            }
        }
        return "";
    }

}
